#include "dialog.h"
#include "ui_dialog.h"
#include<QMessageBox>
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}


void Dialog::on_queetionBtn_clicked()
{
    QMessageBox::StandardButton btn=QMessageBox::question(this,"Question消息框","你是否想退出程序应用,请选择",QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Ok);
    switch(btn)
    {
    case QMessageBox::Ok:
        ui->label->setText("你选择questionMsg命令按钮当中的button/Ok!");
        this->close();
        break;
    case QMessageBox::Cancel:
        ui->label->setText("你选择questionMsg命令按钮当中的button/Cancel!");
        break;
    default:
        break;



    }
    return;
}

void Dialog::on_informationBtn_clicked()
{
    ui->label->setText("information MessageBox");
   QMessageBox::information(this,"Information消息框","Information消息框测试成功，大家可以自己描述");
   return;
}

void Dialog::on_waringBtn_clicked()
{
    ui->label->setText("warnning QMessageBox");
    QMessageBox::StandardButton btn=QMessageBox::warning(this,"Warning消息框",
                                    "是否删除数据库sudent.mdb，请注意数据的操作安全?",
                                    QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel,QMessageBox::Save);
    switch(btn)
    {
    case QMessageBox::Save:
        ui->label->setText("你选择warningMsg命令按钮当中的button/Save!");
        break;
    case QMessageBox::Discard:
        ui->label->setText("你选择warningMsg命令按钮当中的button/Discard!");
        break;
    case QMessageBox::Cancel:
        ui->label->setText("你选择warningMsg命令按钮当中的button/Cancel!");
        break;
    default:
        break;
    }
    return ;

}

void Dialog::on_criticalBtn_clicked()
{
    ui->label->setText("critical QMessageBox");
    QMessageBox::critical(this,"critical消息框","数据库文件备份错误，请重新检查？");
    return ;

}

void Dialog::on_aboutBtn_clicked()
{
    ui->label->setText("about QMessageBox");
    QMessageBox::about(this,"about消息框","测试Qt about消息框");
    return ;
}

void Dialog::on_aboutQtBtn_clicked()
{
    ui->label->setText("aboutQt QMessageBox");
    QMessageBox::aboutQt(this,"aboutQt消息框测试--Vico老师");
    return ;

}
